package com.tch.service;


import com.tch.entity.Plain;
import com.tch.entity.UserEntity;
import com.tch.mapper.OrderMapper;
import com.tch.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class UserServive {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private OrderMapper orderMapper;

    @RequestMapping("/inserUser")
    public boolean inserUser(String userName,Integer age){
        int update = jdbcTemplate.update("insert into t_crj_push_log(order_no,msg,bak1) values ('A2021',?,?)",userName,age);
        return update>0 ?true:false;
    }

    @RequestMapping("/findUserById")
    public UserEntity findUserById(String id){
        return userMapper.findUserById(id);
    }

    @RequestMapping("/insertUsermybatis")
    public String insertUsermybatis(String id,String userName,Integer age){
        int insert = userMapper.inserUser1(id,userName, age);
        System.out.println(insert);
        log.info("1111111");
        return insert>0 ? "true1":"false";
    }

    @RequestMapping("/findInfo")
    public Plain findInfo(){
        Plain plain = orderMapper.findinfo();
        return plain;
    }
}
